﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace NCS.IConnect.Core.WebApi.Configuration
{
    /// <summary>
    /// This <see cref="ConfigurationElement"/> is used to configure default cache-control settings for web api.
    /// </summary>
    [ComVisible(false)]
    public class CacheControlElement : ConfigurationElement
    {
        private const string PublicPropertyName = "public";
        private const string NoStoreProperytName = "noStore";
        private const string MaxAgePropertyName = "maxAge";

        /// <summary>
        /// Whether an HTTP response may be cached by any cache, even if it would normally be non-cacheable or cacheable only within a non- shared cache.
        /// </summary>
        [ConfigurationProperty(PublicPropertyName, IsRequired = false, DefaultValue = false)]
        public bool Public
        {
            get {return  (bool) base[PublicPropertyName]; }
        }

        /// <summary>
        /// Whether a cache must not store any part of either the HTTP request mressage or any response.
        /// </summary>
        [ConfigurationProperty(NoStoreProperytName, IsRequired = false, DefaultValue = false)]
        public bool NoStore
        {
            get {return  (bool) base[NoStoreProperytName]; }
        }

        /// <summary>
        /// The maximum age, specified in seconds, that the HTTP client is willing to accept a response.
        /// </summary>
        [ConfigurationProperty(MaxAgePropertyName, IsRequired = false, DefaultValue = "00:30:00")]
        public TimeSpan MaxAge
        {
            get {return  (TimeSpan) base[MaxAgePropertyName]; }
        }
    }
}
